<template>
  <a-card :loading="loading" :bordered="false" style="margin-top: 12px">
    <a-row>
      <a-col :sm="8" :xs="24">
        <head-info title="分院总课时" :content="totalClasstime" :bordered="true"/>
      </a-col>
      <a-col :sm="8" :xs="24">
        <head-info title="分院人均课时" :content="averageClasstime" :bordered="true"/>
      </a-col>
      <a-col :sm="8" :xs="24">
        <head-info title="分院专职教师人数" :content="teacherCounts"/>
      </a-col>
    </a-row>
  </a-card>
</template>

<script>
import HeadInfo from '@/components/tools/HeadInfo'
import { getAction } from '@api/manage'


export default {
  name: 'DepartmentClasstimeInfo',
  components:{
    HeadInfo
  },
  props: {
    date: {
      type: String,
      default: ''
    },
    orgCode: {
      type: String,
      default: ''
    },
  },
  data(){
    return {
      loading: true,
      totalClasstime:0,
      averageClasstime:0,
      teacherCounts:0,
      url: {
        getDataUrl:'index/departmentIndex/listClasstimeByYearAndOrgCode'
      }
    }
  },
  watch:{
    date: function(){
      this.loadData();
    },
    orgCode: function(){
      this.loadData();
    }
  },
  methods: {
    loadData(){
      getAction(this.url.getDataUrl, { date: this.date, orgCode: this.orgCode}).then((res) => {
        if (res.success) {
          console.log(res.result);

          this.totalClasstime = res.result.total;
          this.averageClasstime = res.result.average
          this.teacherCounts = res.result.teacherCount

        }
        // console.log(this.options)
        if(res.code===510){
          this.$message.warning(res.message)
        }
        this.loading = false;
      })
    }
  },
  mounted() {
    this.loadData();
  }
}
</script>

<style scoped>

</style>